from playwright.sync_api import Page, expect


class BasePage:
    def __init__(self, page: Page):
        self.page = page
        self.base_url = 'https://team.pescms.com/?'

    def click(self, selector: str):
        self.page.locator(selector).click()

    def fill(self, selector: str, text: str):
        self.page.locator(selector).fill(text)

    def get_text(self, selector: str) -> str:
        return self.page.inner_text(selector)

    def wait_for_selector(self, selector: str, timeout=5000):
        self.page.wait_for_selector(selector, timeout=timeout)

    def should_contain_text(self, selector: str, text: str):
        expect(self.page.locator(selector)).to_contain_text(text)

    def choose_option(self, selector: str, option: str):
        self.page.select_option(selector, option)

    def page_waiter(self, timeout=5000):
        self.page.wait_for_timeout(timeout)
